# -*-coding:utf-8 -*-
#author: LeoKim

import pymysql
import configparser

conf = configparser.ConfigParser()
conf.read('config.ini')

#连接数据库
conn = pymysql.connect(
    host = conf.get('config', 'host'),
    user = conf.get('config', 'user'),
    password = conf.get('config', 'password'),
    database = conf.get('config', 'database'),
    charset = conf.get('config', 'charset'),
    cursorclass = pymysql.cursors.DictCursor
    )


def update_files(floder, md5_f1, f1_size, md5_f2, f2_size, md5):
    cursor = conn.cursor()

    sql = "update files set floder = '"+floder+"', md5_f1 = '"+md5_f1+"', f1_size = '"+str(f1_size)+"', md5_f2 = '"+md5_f2+"', f2_size = '"+str(f2_size)+"' where md5 = '"+md5+"'"
    cursor.execute(sql)
    conn.commit()

    cursor.close()

#关闭了这个conn 主文件里的conn也就关闭了
# conn.close()


